package com.onlineMIS.ORM.entity.chainS.sales;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;

import com.onlineMIS.common.ExcelTemplate;

public class ChainSalesOrderTemplate extends ExcelTemplate{
	
	private final int header_row1_ind = 2;

	private List<ChainStoreSalesOrderVO> list = new ArrayList<ChainStoreSalesOrderVO>();

	public ChainSalesOrderTemplate(List<ChainStoreSalesOrderVO> list,String templateWorkbookPath) throws IOException {
		super(templateWorkbookPath);
		this.list = list;
	}
	
	
	public HSSFWorkbook process() {
		HSSFSheet sheet = templateWorkbook.getSheetAt(0);
		int totalDataRow = list.size();
		for (int i = 0; i < totalDataRow; i++){
			ChainStoreSalesOrderVO item = list.get(i);
			Row row = sheet.createRow(header_row1_ind + i);
			if (item.getId() !=0) {
				row.createCell(0).setCellValue(item.getId());
			}			
			row.createCell(1).setCellValue(item.getChainName());
			if (item.getOrderDate() !=null) {
				row.createCell(2).setCellValue(item.getOrderDate());
			}
			if (item.getOrderCreateDate() !=null) {
				row.createCell(3).setCellValue(item.getOrderCreateDate());
			}			
			row.createCell(4).setCellValue(item.getStatusS());
			row.createCell(5).setCellValue(item.getIsVip());
			row.createCell(6).setCellValue(item.getChainSalerName());
			row.createCell(7).setCellValue(item.getTotalQuantity());
			row.createCell(8).setCellValue(item.getNetAmount());			
			row.createCell(9).setCellValue(item.getTotalQuantityR());
			row.createCell(10).setCellValue(item.getNetAmountR());
			//净销售 = 销售金额 - 退货金额
			row.createCell(11).setCellValue(item.getNetAmount() - item.getNetAmountR());
			row.createCell(12).setCellValue(item.getTotalQuantityF());
			row.createCell(13).setCellValue(item.getMemo());

		}
		return templateWorkbook;
	}
	

}
